package com.star.spring.ai.controller;


import com.star.spring.ai.service.BookingTools.BookingDetails;
import com.star.spring.ai.service.FlightBookingService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @description: 订票控制类
 * @author: star
 * @create: 2024-12-03 09:39
 **/

@RestController
@RequestMapping("/booking")
public class BookingController {

    @Autowired
    private FlightBookingService flightBookingService;

    @GetMapping("/get")
    public BookingDetails bookFlight(String flightNumber, String firstName, String lastName) {
        return flightBookingService.getBookingDetails(flightNumber, firstName, lastName);
    }

    @GetMapping("/list")
    public List<BookingDetails> list() {
        return flightBookingService.getBookings();
    }

    @GetMapping("/cancel")
    public void delete(String flightNumber, String firstName, String lastName) {
        flightBookingService.cancelBooking(flightNumber, firstName, lastName);
    }

    @GetMapping("/change")
    public void change(String flightNumber, String firstName, String lastName, String newDate, String from, String to) {
        flightBookingService.changeBooking(flightNumber, firstName, lastName, newDate, from, to);
    }
}
